/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.netcracker.test.nine;

import java.util.ArrayList;

/**
 *
 * @author I
 */
public class APIFirm {
    public void getEmployersOnProject(ArrayList<Employer> empl, int index)
    {
        for(Employer i: empl)
        {
            for(Integer j:i.getListProject() )
            {
                if(j.intValue()==index)
                    System.out.println(i.getName()+" "+i.getSurname());
            }
        }
    }
    public void getProjectOnEmployers(ArrayList<Project> pr, Employer em)
    {
        for(Integer i:em.getListProject() )
        {
            System.out.println(pr.get(i).getName());
        }
        
    }
    public void getEmployersNotProjectInDep(ArrayList<Employer> em, int index)
    {
        for(Employer i:em)
        {
            if(i.getiDDepartment()==index&&i.getListProject().isEmpty())
            System.out.println(i.getName()+" "+i.getSurname());
        }
        
    }
    public void getEmployersNotProject(ArrayList<Employer> em)
    {
        for(Employer i:em)
        {
            if(i.getListProject().isEmpty())
            System.out.println(i.getName()+" "+i.getSurname());
        }
        
    }
    public void getListObey(ArrayList<Employer> em, ArrayList<Project> pr, int index)
    {
        ArrayList<Integer> list = new ArrayList<Integer>();
        list.add(index);
        boolean flag;
        for (int i = 0; i < pr.size(); i++) 
        {
            if(pr.get(i).getHead()==index)
            {
                for(int k=0; k<em.size(); k++)
                {
                    
                    for(Integer n:em.get(k).getListProject())
                    {
                        if(n.intValue()==i)
                        {
                            flag=false;
                           // System.out.println(em.get(k).getName() +" "+em.get(k).getSurname());
                            for(Integer it:list)
                            {
                                if(it.intValue()==k)
                                {
                                    flag=true;
                                    break;
                                }
                            }
                            if(flag==false)
                            {
                                list.add(k);
                                break;
                            }
                        }
                    }
                }
            }
        }
        for(Integer i:list)
            System.out.println(em.get(i.intValue()).getName() +" "+em.get(i.intValue()).getSurname());
    }
    public void getListHead(ArrayList<Employer> em, ArrayList<Project> pr, int index)
    {
        ArrayList<Integer> list = new ArrayList<Integer>();
        list.add(index);
        boolean flag;
        for (int i = 0; i < em.get(index).getListProject().size(); i++) 
        {
            flag=false;
            // System.out.println(em.get(k).getName() +" "+em.get(k).getSurname());
            for(Integer it:list)
            {
                if(pr.get(em.get(index).getListProject().get(i).intValue()).getHead()==it.intValue())
                {
                    flag=true;
                    break;
                }
            }
            if(flag==false)
            {
                list.add(pr.get(em.get(index).getListProject().get(i).intValue()).getHead());
            }
        }
        for(Integer i:list)
            System.out.println(em.get(i.intValue()).getName() +" "+em.get(i.intValue()).getSurname());
    }
    public void getListEmpl(ArrayList<Employer> em, ArrayList<Project> pr, int index)
    {
        ArrayList<Integer> list = new ArrayList<Integer>();
        list.add(index);
        boolean flag;
        for (int n = 0; n < em.get(index).getListProject().size(); n++) 
        {
            for (int i = 0; i < em.size(); i++) 
            {
                for (int j = 0; j < em.get(i).getListProject().size(); j++) 
                {
                    if(em.get(index).getListProject().get(n).intValue()==em.get(i).getListProject().get(j).intValue())
                    {
                        flag=false;
            // System.out.println(em.get(k).getName() +" "+em.get(k).getSurname());
                        for(Integer it:list)
                        {
                            if(i==it.intValue())
                            {
                                flag=true;
                                break;
                            }
                        }
                        if(flag==false)
                        {
                            list.add(i);
                        }
                    }
                }
            }
        }
        for(Integer i:list)
            System.out.println(em.get(i.intValue()).getName() +" "+em.get(i.intValue()).getSurname());
    }
    public void getListProjectForOrder(ArrayList<Project> pr, int index)
    {
        for (int i = 0; i < pr.size(); i++) 
        {
            if(pr.get(i).getCustomer()==index)
                System.out.println(pr.get(i).getName());
        }
    }
  
    public void getListEmployersONCustom(ArrayList<Employer> em, ArrayList<Project> pr, int index)
    {
        ArrayList<Integer> list = new ArrayList<Integer>();
        list.add(index);
        boolean flag;
        for (int i = 0; i < pr.size(); i++) 
        {
            if(pr.get(i).getCustomer()==index)
            {
                for (int j = 0; j < em.size(); j++) 
                {
                    for (int k = 0; k < em.get(j).getListProject().size(); k++) 
                    {
                        if(em.get(j).getListProject().get(k).intValue()==i)
                        {
                            flag=false;
                // System.out.println(em.get(k).getName() +" "+em.get(k).getSurname());
                            for(Integer it:list)
                            {
                                if(j==it.intValue())
                                {
                                    flag=true;
                                    break;
                                }
                            }
                            if(flag==false)
                            {
                                list.add(j);
                            }
                        }
                        
                    }
                }
            }
        }
        for(Integer i:list)
            System.out.println(em.get(i.intValue()).getName() +" "+em.get(i.intValue()).getSurname());
    }
}